package com.evolved.automata.examples.sudoku;
import com.evolved.automata.algorithms.interruptible.*;
import java.util.*;

public class SudokuChoiceNode implements ChoiceNode {
	private LinkedList<SudokuAction> j_PossibleBoardTransforms;

	SudokuBoard j_Board;
	SudokuAction j_PreviousAction;
	public SudokuChoiceNode(SudokuBoard board)
	{
		j_Board=board;
		j_PossibleBoardTransforms = new LinkedList<SudokuAction>();
		j_PreviousAction=null;
	}
	/**
	 * 
	 * @param action
	 */
	public void AddActionPossibility(SudokuAction action){
		j_PossibleBoardTransforms.add(action);
	}

	public boolean GoalReachedP(){
		return j_Board.FinishedP();
	}

	public ChoicePointer NextChoice(){
		if (j_PreviousAction!=null)
			j_PreviousAction.Undo();
		if (j_PossibleBoardTransforms.size()==0)
			return null;
		else
		{
			j_PreviousAction=j_PossibleBoardTransforms.removeFirst();
			return j_PreviousAction;
		}
	}

	public void ResetNode(){

	}
}
